//
//  LGOutPatientRecordCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/3/20.
//

#import "LGPatientIORecordCell.h"

@interface LGPatientIORecordCell()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIView *bottomView;
/**   */
@property (nonatomic , strong)UILabel *abdominTitle;
/**   */
@property (nonatomic , strong)UILabel *unitLabel;
/**   */
@property (nonatomic , strong)UILabel *timeLabel;
/**   */
@property (nonatomic , strong)UILabel *valueLabel;
/**  差值 */
@property (nonatomic , strong)UIButton *differBtn;

@end

@implementation LGPatientIORecordCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.timeLabel.text = LGNSString(dataDic[@"rtime"]);
    self.valueLabel.text = LGNSString(dataDic[@"acvalue"]);
    NSString *status = LGNSString(dataDic[@"status"]);
    self.differBtn.hidden = NO;
    if([status isEqualToString:@"high"]){
        [self.differBtn setTitleColor:[UIColor colorWithString:@"#DB453A"] forState:UIControlStateNormal];
        [self.differBtn setImage:[UIImage imageNamed:@"腹围-上升"] forState:UIControlStateNormal];
    }else if ([status isEqualToString:@"low"]){
        [self.differBtn setTitleColor:[UIColor colorWithString:@"#2EAF71"] forState:UIControlStateNormal];
        [self.differBtn setImage:[UIImage imageNamed:@"腹围-下降"] forState:UIControlStateNormal];
    }else{
        self.differBtn.hidden = YES;
        [self.differBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
    }
    [self.differBtn setTitle:LGNSString(dataDic[@"dvalue"]) forState:UIControlStateNormal];
}


-(void)createSubView{
    self.clipsToBounds = YES;
    self.backgroundColor = [UIColor clearColor];
    self.contentView.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.baseView];
    [self.contentView addSubview:self.bottomView];
    [self.contentView addSubview:self.abdominTitle];
    [self.contentView addSubview:self.unitLabel];
    [self.contentView addSubview:self.timeLabel];
    [self.contentView addSubview:self.valueLabel];
    [self.contentView addSubview:self.differBtn];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.equalTo(self.contentView).offset(viewPix(16));
        make.top.right.equalTo(self.contentView).offset(-viewPix(16));
    }];
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.equalTo(self.baseView);
    }];
    [self.abdominTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(viewPix(32));
        make.centerY.equalTo(self.contentView);
    }];
    [self.unitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.abdominTitle.mas_right);
        make.bottom.equalTo(self.abdominTitle);
    }];
    [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.abdominTitle.mas_right).offset(viewPix(35));
        make.centerY.equalTo(self.abdominTitle);
    }];
    
    [self.valueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.timeLabel.mas_right).offset(viewPix(45));
        make.centerY.equalTo(self.timeLabel);
    }];
    [self.differBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.valueLabel.mas_right);
        make.centerY.equalTo(self.valueLabel);
        make.width.equalTo(@(viewPix(60)));
        make.height.equalTo(@(viewPix(18)));
    }];
    
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [[UIView alloc] init];
        _baseView.backgroundColor = [UIColor colorWithString:@"#FFFFFF"];
    }
    return _baseView;
}
-(UIView *)bottomView{
    if(!_bottomView){
        _bottomView = [[UIView alloc] init];
        _bottomView.backgroundColor = [UIColor colorWithString:@"#EAF4FF" alpha:0.5];
    }
    return _bottomView;
}

-(UILabel *)abdominTitle{
    if(!_abdominTitle){
        _abdominTitle = [UILabel lableWithText:@"腹围" colorString:@"#333333" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:0];
    }
    return _abdominTitle;
}

-(UILabel *)unitLabel{
    if(!_unitLabel){
        _unitLabel = [UILabel lableWithText:@"cm" colorString:@"#999999" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _unitLabel;
}

-(UILabel *)timeLabel{
    if(!_timeLabel){
        _timeLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _timeLabel;
}


-(UILabel *)valueLabel{
    if(!_valueLabel){
        _valueLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFont(16) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _valueLabel;
}

-(UIButton *)differBtn{
    if(!_differBtn){
        _differBtn = [UIButton buttonWithTitle:@"" titleFont:LGFont(16) textColor:@"#2EAF71" imageName:@""];
        _differBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    }
    return _differBtn;
}

@end
